<template>
  <div class="page praticle-page flex-col">
    <div class="box_1 flex-row">
      <div class="group_1 ">
        <img class="label_4" src="@/assets/ide/liebiao.png" />
        <span>{{ examTitle ? examTitle : '精选题库' }}</span>
        <!-- 倒计时 -->
        <el-countdown v-if="examEndTime && new Date() < new Date(examEndTime)" class="exam-time-countdown"
          @finish="handleCountdownFinish" title="距离竞赛结束还有:" :value="new Date(examEndTime)" />
      </div>
      <div class="group_2">
        <el-button type="primary" plain @click="submitQuestion">提交代码</el-button>
      </div>
      <span class="ide-back" @click="goBack()">返回</span>
    </div>
    <div class="box_8 flex-col">
      <div class="group_12 flex-row justify-between">
        <div class="image-wrapper_1 flex-row">
          <img class="thumbnail_2" src="@/assets/ide/xiaobiaoti.png" />
          <div class="question-nav">
            <span>题目描述</span>
          </div>
          <div class="question-nav" @click="preQuestion">
            <el-icon>
              <span>上一题</span>
              <ArrowLeft />
            </el-icon>
          </div>
          <div class="question-nav" @click="nextQuestion">
            <el-icon>
              <ArrowRight />
              <span>下一题</span>
            </el-icon>
          </div>
        </div>
        <div class="image-wrapper_2 flex-row">
          <img class="image_1" src="@/assets/ide/daima.png" />
          代码
        </div>
      </div>
      <div class="group_13 flex-row justify-between">
        <div class="box_3 flex-col">
          <span class="question-title">{{ questionDetail.title }}</span>
          <span class="question-limit">
            <div v-if="questionDetail.difficulty === 1">题目难度：简单 时间限制：{{ questionDetail.timeLimit }} ms 空间限制：{{
              questionDetail.spaceLimit }} 字节</div>
            <div v-if="questionDetail.difficulty === 2">题目难度：中等 时间限制：{{ questionDetail.timeLimit }} ms 空间限制：{{
              questionDetail.spaceLimit }} 字节</div>
            <div v-if="questionDetail.difficulty === 3">题目难度：困难 时间限制：{{ questionDetail.timeLimit }} ms 空间限制：{{
              questionDetail.spaceLimit }} 字节</div>
          </span>
          <span class="question-content" v-html="questionDetail.content"></span>
        </div>
        <div class="group_14 flex-col">
          <div class="group_8 flex-col">
            <codeEditor ref="defaultCodeRef" @update:value="handleEditorContent">
            </codeEditor>
          </div>
          <div class="code-result flex-row">
            <img class="code-result-image" src="@/assets/ide/codeResult.png" />
            <span class="code-result-content">执行结果</span>
          </div>
          <div class="group_15 flex-row">
            <div class="section_1 flex-row">
              <div class="section_3 flex-col">
                <div class="text-wrapper_2 flex-row justify-between">
                  <span class="text_1 red" v-if="userQuestionResultVO.pass === 0">未通过</span>
                  <span class="text_1 success" v-if="userQuestionResultVO.pass === 1">通过</span>
                  <span class="text_1 warning" v-if="userQuestionResultVO.pass === 2">请先执行代码</span>
                  <span class="text_1 info" v-if="userQuestionResultVO.pass === 3">系统正在处理您的代码，请稍后</span>
                </div>
                <span class="error-text" v-if="userQuestionResultVO.pass === 0">异常信息：{{
                  userQuestionResultVO.exeMessage }}</span>
                <el-table v-if="userQuestionResultVO.userExeResultList && userQuestionResultVO.userExeResultList.length > 0"
                  :data="userQuestionResultVO.userExeResultList">
                  <el-table-column prop="input" label="输入" />
                  <el-table-column prop="output" label="预期结果" />
                  <el-table-column prop="exeOutput" label="实际输出" />
                </el-table>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 可拖动机器人 -->
    <div 
      class="floating-robot" 
      :style="{ left: robotPosition.x + 'px', top: robotPosition.y + 'px' }"
      @mousedown="startDrag"
      @click="toggleChatWindow"
    >
      <div class="robot-icon">
        <el-icon size="24">
          <ChatDotRound />
        </el-icon>
      </div>
      <div class="robot-pulse" v-if="!isChatOpen"></div>
    </div>

    <!-- 聊天悬浮窗 -->
    <div 
      v-if="isChatOpen" 
      class="chat-floating-window"
      :style="{ left: chatWindowPosition.x + 'px', top: chatWindowPosition.y + 'px' }"
    >
      <div class="chat-window-header" @mousedown="startChatWindowDrag">
        <span class="chat-title">智能助手</span>
        <div class="chat-controls">
          <el-button 
            link
            size="small" 
            @click="minimizeChat"
            class="minimize-btn"
          >
            <el-icon><Minus /></el-icon>
          </el-button>
          <el-button 
            link
            size="small" 
            @click="closeChat"
            class="close-btn"
          >
            <el-icon><Close /></el-icon>
          </el-button>
        </div>
      </div>
      <div class="chat-window-content">
        <Chat />
      </div>
    </div>
  </div>
</template>

<script setup>
import { reactive, ref, onMounted, onUnmounted } from "vue"
import codeEditor from "@/components/CodeEditor.vue"
import Chat from "@/views/Chat.vue"
import { ArrowLeft, ArrowRight, ChatDotRound, Minus, Close } from '@element-plus/icons-vue'
import { useRoute } from "vue-router"
import { getQuestionDetailService, preQuestionService, nextQuestionService, getQuestionResultService } from "@/apis/question"
import router from "@/router"
import { examNextQuestionService, examPreQuestionService, getExamFirstQuestionService } from "@/apis/exam"
import { ElMessage } from "element-plus"
import { userSubmitService } from "@/apis/user"

function goBack() {
  router.go(-1);
}
const questionDetail = reactive({})
const defaultCodeRef = ref()

let questionId = useRoute().query.questionId
let examId = useRoute().query.examId 
let examTitle = useRoute().query.examTitle
let examEndTime = useRoute().query.examEndTime

console.log('examTitle: ', examTitle)

async function getQuestionDetail() {
  if (examId && (questionId == null || questionId == '')) {
    const eqrs = await getExamFirstQuestionService(examId)
    questionId = eqrs.data
    console.log('qId: ', questionId)
  }
  const res = await getQuestionDetailService(questionId)
  Object.assign(questionDetail, res.data)
  defaultCodeRef.value.setAceCode(questionDetail.defaultCode)
}
getQuestionDetail()

async function preQuestion() {
  if (examId) {
    //竞赛中上一题的逻辑  需要提供一个竞赛中获取上一题的接口
    const res = await examPreQuestionService(examId, questionId)
    questionId = res.data
  } else {
    const res = await preQuestionService(questionId)
    questionId = res.data
  }
  getQuestionDetail()
}

async function nextQuestion() {
  if (examId) {
    //竞赛中下一题的逻辑 需要提供一个竞赛中获取下一题的接口
    const res = await examNextQuestionService(examId, questionId)
    questionId = res.data
  } else {
    const res = await nextQuestionService(questionId)
    questionId = res.data
  }
  getQuestionDetail()
}

//当倒计时组件结束时
function handleCountdownFinish() {
  ElMessage.info('竞赛已经结束了哦')
  router.push('/c-oj/home/exam')
}

const submitDTO = reactive({
  examId:'',
  questionId:'',
  programType: 0,
  userCode: ''
})

function handleEditorContent(content) {
  submitDTO.userCode = content
}

const userQuestionResultVO = ref({
  pass: 2,  //默认值为2，未提交代码
  exeMessage: '',
  userExeResultList: [],
})

const pollingInterval = ref(null);
let currentTime

function startPolling() {
  stopPolling(); // 停止之前的轮询
  pollingInterval.value = setInterval(() => {
    getQuestionResult();
  }, 2000); // 每隔2秒请求一次
}

function stopPolling() {
  if (pollingInterval.value) {
    clearInterval(pollingInterval.value);
    pollingInterval.value = null;
  }
}

async function submitQuestion() {
  submitDTO.examId = examId
  submitDTO.questionId = questionId
  await userSubmitService(submitDTO)
  currentTime = new Date().toLocaleString();
  userQuestionResultVO.value.pass = 3
  startPolling()
}

async function getQuestionResult() {
  const res = await getQuestionResultService(submitDTO.examId, submitDTO.questionId, currentTime)
  userQuestionResultVO.value = res.data
  if (userQuestionResultVO.value.pass !== 3) {
    stopPolling();
  }
}

// 机器人相关状态
const isChatOpen = ref(false)
const robotPosition = ref({ x: 0, y: 0 })
const chatWindowPosition = ref({ x: 0, y: 0 })
const isDragging = ref(false)
const isChatWindowDragging = ref(false)
const dragStart = ref({ x: 0, y: 0 })

// 初始化机器人位置
onMounted(() => {
  // 设置机器人初始位置为右下角
  robotPosition.value = {
    x: window.innerWidth - 80,
    y: window.innerHeight - 80
  }
  
  // 设置聊天窗口初始位置
  chatWindowPosition.value = {
    x: window.innerWidth - 420,
    y: window.innerHeight - 600
  }
})

// 机器人拖拽功能
function startDrag(e) {
  if (e.target.closest('.chat-controls')) return // 防止在聊天窗口控制按钮上拖拽
  
  isDragging.value = true
  dragStart.value = {
    x: e.clientX - robotPosition.value.x,
    y: e.clientY - robotPosition.value.y
  }
  
  document.addEventListener('mousemove', onRobotDrag)
  document.addEventListener('mouseup', stopRobotDrag)
  e.preventDefault()
}

function onRobotDrag(e) {
  if (!isDragging.value) return
  
  const newX = e.clientX - dragStart.value.x
  const newY = e.clientY - dragStart.value.y
  
  // 限制在视窗范围内
  robotPosition.value = {
    x: Math.max(0, Math.min(newX, window.innerWidth - 60)),
    y: Math.max(0, Math.min(newY, window.innerHeight - 60))
  }
}

function stopRobotDrag() {
  isDragging.value = false
  document.removeEventListener('mousemove', onRobotDrag)
  document.removeEventListener('mouseup', stopRobotDrag)
}

// 聊天窗口拖拽功能
function startChatWindowDrag(e) {
  isChatWindowDragging.value = true
  dragStart.value = {
    x: e.clientX - chatWindowPosition.value.x,
    y: e.clientY - chatWindowPosition.value.y
  }
  
  document.addEventListener('mousemove', onChatWindowDrag)
  document.addEventListener('mouseup', stopChatWindowDrag)
  e.preventDefault()
}

function onChatWindowDrag(e) {
  if (!isChatWindowDragging.value) return
  
  const newX = e.clientX - dragStart.value.x
  const newY = e.clientY - dragStart.value.y
  
  // 限制在视窗范围内
  chatWindowPosition.value = {
    x: Math.max(0, Math.min(newX, window.innerWidth - 400)),
    y: Math.max(0, Math.min(newY, window.innerHeight - 500))
  }
}

function stopChatWindowDrag() {
  isChatWindowDragging.value = false
  document.removeEventListener('mousemove', onChatWindowDrag)
  document.removeEventListener('mouseup', stopChatWindowDrag)
}

// 切换聊天窗口
function toggleChatWindow(e) {
  if (isDragging.value) return // 如果正在拖拽，不切换窗口
  
  isChatOpen.value = !isChatOpen.value
  
  if (isChatOpen.value) {
    // 打开聊天窗口时，调整位置使其靠近机器人
    chatWindowPosition.value = {
      x: Math.max(0, robotPosition.value.x - 360),
      y: Math.max(0, robotPosition.value.y - 500)
    }
  }
}

// 最小化聊天窗口
function minimizeChat() {
  isChatOpen.value = false
}

// 关闭聊天窗口
function closeChat() {
  isChatOpen.value = false
}

// 清理事件监听器
onUnmounted(() => {
  document.removeEventListener('mousemove', onRobotDrag)
  document.removeEventListener('mouseup', stopRobotDrag)
  document.removeEventListener('mousemove', onChatWindowDrag)
  document.removeEventListener('mouseup', stopChatWindowDrag)
})

</script>

<style lang="scss" scoped>
.praticle-page {
  margin-top: -40px;

  .box_1 {
    background-color: rgba(240, 240, 240, 1);
    height: 60px;
    display: flex;
    align-items: center;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;

    /* 垂直居中 */

    .box_1 span {
      margin-right: 10px;
      /* 文字与图片之间的间距 */
    }

    .exam-time-countdown {
      margin: 0 0 0 400px;
    }

    .group_1 {
      display: flex;
      align-items: center;

      img {
        margin-right: 10px;
      }
    }

    .thumbnail_1 {
      width: 1px;
      height: 20px;
      margin: 20px 0 0 8px;
    }

    .label_4 {
      width: 26px;
      height: 26px;
    }

    

    .group_3 {
      cursor: pointer;
      background-color: rgba(7, 126, 255, 0.1);
      border-radius: 0px 6px 6px 0px;
      width: 100px;
      height: 40px;
      margin: 10px 0 0 2px;
      font-size: 20px;

      display: flex;
      justify-content: center;
      align-items: center;
    }

    .ide-back {
      cursor: pointer;
      color: #999999;
    }

    .label_2 {
      width: 30px;
      height: 30px;
      margin: 15px 0 0 500px;
    }

    .label_3 {
      width: 30px;
      height: 30px;
      margin: 15px 70px 0 30px;
    }
  }
}

.page {
  background-color: rgba(247, 247, 247, 1);
  position: relative;
  height: 910px;
  overflow: hidden;

  .box_8 {
    position: relative;
    width: 100%;
    height: 1451px;
    margin-bottom: 1px;

    .group_12 {
      width: 100%;
      height: 64px;
      margin-top: 10px;

      .image-wrapper_1 {
        background-color: rgba(240, 240, 240, 1);
        border-radius: 10px 10px 0px 0px;
        height: 64px;
        width: 600px;
        margin: 0 10px 10px 0;

        display: flex;
        align-items: center;
        /* 垂直居中 */

        .thumbnail_2 {
          width: 14px;
          height: 15px;
          margin: 0 10px 0 19px;
        }

        .question-nav {
          cursor: pointer;
          margin-right: 100px;
          display: flex;
          align-items: center;
        }
      }

      .image-wrapper_2 {
        background-color: rgba(240, 240, 240, 1);
        border-radius: 10px 10px 0px 0px;
        height: 64px;
        display: flex;
        align-items: center;
        flex: 1;
        /* 垂直居中 */

        .image_1 {
          width: 21px;
          height: 16px;
          margin: 0 10px 0 19px;
        }
      }
    }

    .group_13 {
      height: 904px;

      .box_3 {
        background-color: rgba(255, 255, 255, 1);
        border-radius: 10px;
        height: 765px;
        width: 600px;
        margin-right: 10px;

        .question-title {
          font-weight: bold;
          font-size: 28px;
          margin-top: 20px;
          margin-left: 20px;
          margin-bottom: 10px;
        }

        .question-limit {
          font-size: 18px;
          color: #abaeac;
          margin-left: 20px;
          margin-bottom: 10px;
        }

        .question-content {
          font-size: 20px;
          margin-left: 20px;
        }

        .group_6 {
          background-color: rgba(241, 241, 241, 1);
          width: 21px;
          height: 874px;
          justify-content: flex-center;
          margin: 10px 0 0 923px;

          .thumbnail_3 {
            width: 9px;
            height: 6px;
            margin: 10px 0 0 6px;
          }

          .group_7 {
            background-color: rgba(192, 192, 192, 1);
            width: 16px;
            height: 296px;
            margin: 10px 0 0 3px;
          }

          .thumbnail_4 {
            width: 9px;
            height: 6px;
            margin: 536px 0 10px 6px;
          }
        }
      }

      .group_14 {
        height: 904px;
        display: flex;
        width: calc(100vw - 663px);

        .group_8 {
          background-color: rgba(255, 255, 255, 1);
          border-radius: 10px;
          flex: 1;

          .thumbnail_5 {
            width: 11px;
            height: 6px;
            margin: 31px 0 0 69px;
          }

          .block_1 {
            width: 21px;
            height: 710px;
            border: 1px solid rgba(241, 241, 241, 1);
            margin: 19px 0 0 923px;
          }

          .image_2 {
            width: calc(100vw - 663px);
            height: 1px;
            margin: -710px 0 763px 0;
          }
        }

        .code-result {
          background-color: rgba(240, 240, 240, 1);
          border-radius: 10px 10px 0px 0px;
          height: 64px;
          margin-top: 20px;
          width: calc(100vw - 663px);

          .code-result-image {
            width: 27px;
            height: 27px;
            margin: 24px 0 0 20px;
          }

          .code-result-content {
            margin: 26px 0 0 5px;
          }
        }
      }
    }

    .group_15 {
      width: calc(100vw - 663px);
      height: 452px;

      .section_1 {
        background-color: rgba(255, 255, 255, 1);
        border-radius: 0px 0px 10px 10px;
        width: 100%;
        height: 200px;

        .section_3 {
          width: 100%;
          height: 286px;
          margin: 24px 0 0 20px;

          .error-text {
            padding: 6px 20px;
            font-size: 14px;
            color: #666;
            background: #f7f7f7;
            border-left: 2px solid red;
            width: 95%;
          }

          .text-wrapper_2 {
            width: 217px;
            height: 40px;

            .text_1 {
              width: 60px;
              height: 40px;
              overflow-wrap: break-word;
              color: rgba(7, 126, 255, 1);
              font-size: 20px;
              font-family: MicrosoftYaHei;
              font-weight: normal;
              text-align: left;
              white-space: nowrap;
              line-height: 40px;

              &.red {
                color: red;
              }

              &.info {
                color: #32C5FF;
              }

              &.success {
                color: green;
              }

              &.warning {
                color: orange;
              }
            }

            .text_2 {
              width: 137px;
              height: 24px;
              overflow-wrap: break-word;
              color: rgba(153, 153, 153, 1);
              font-size: 18px;
              font-family: MicrosoftYaHei;
              font-weight: normal;
              text-align: left;
              white-space: nowrap;
              line-height: 24px;
              margin-top: 13px;
            }
          }

          .box_9 {
            width: 382px;
            height: 50px;
            margin-top: 10px;

            .box_5 {
              background-color: rgba(242, 243, 245, 1);
              border-radius: 8px;
              width: 100px;
              height: 40px;

              .section_2 {
                background-color: rgba(7, 126, 255, 1);
                border-radius: 50%;
                width: 5px;
                height: 5px;
                margin: 23px 0 0 24px;
              }

              .text_3 {
                width: 63px;
                height: 26px;
                overflow-wrap: break-word;
                color: rgba(34, 34, 34, 1);
                font-size: 15px;
                font-family: MicrosoftYaHei;
                font-weight: normal;
                text-align: right;
                white-space: nowrap;
                line-height: 26px;
                margin: 10px 4px 0 0;
              }
            }

            .box_6 {
              background-color: rgba(153, 153, 153, 1);
              border-radius: 50%;
              width: 5px;
              height: 5px;
              margin: 23px 0 0 44px;
            }

            .text_4 {
              width: 63px;
              height: 26px;
              overflow-wrap: break-word;
              color: rgba(153, 153, 153, 1);
              font-size: 20px;
              font-family: MicrosoftYaHei;
              font-weight: normal;
              text-align: right;
              white-space: nowrap;
              line-height: 26px;
              margin: 12px 0 0 6px;
            }

            .box_7 {
              background-color: rgba(153, 153, 153, 1);
              border-radius: 50%;
              width: 5px;
              height: 5px;
              margin: 23px 0 0 68px;
            }

            .text_5 {
              width: 63px;
              height: 26px;
              overflow-wrap: break-word;
              color: rgba(153, 153, 153, 1);
              font-size: 20px;
              font-family: MicrosoftYaHei;
              font-weight: normal;
              text-align: right;
              white-space: nowrap;
              line-height: 26px;
              margin: 12px 0 0 6px;
            }
          }

          .text_6 {
            width: 40px;
            height: 26px;
            overflow-wrap: break-word;
            color: rgba(102, 102, 102, 1);
            font-size: 20px;
            font-family: MicrosoftYaHei;
            font-weight: normal;
            text-align: right;
            white-space: nowrap;
            line-height: 26px;
            margin-top: 24px;
          }

          .block_4 {
            background-color: rgba(242, 243, 245, 1);
            border-radius: 8px;
            width: 883px;
            height: 106px;
            margin-top: 16px;
          }
        }

        .block_5 {
          background-color: rgba(241, 241, 241, 1);
          width: 20px;
          height: 422px;
          justify-content: flex-center;
          margin: 10px 1px 0 20px;

          .thumbnail_7 {
            width: 9px;
            height: 6px;
            margin: 10px 0 0 6px;
          }

          .group_10 {
            background-color: rgba(192, 192, 192, 1);
            width: 16px;
            height: 296px;
            margin: 10px 0 0 3px;
          }

          .thumbnail_8 {
            width: 9px;
            height: 6px;
            margin: 84px 0 10px 6px;
          }
        }
      }
    }

    .group_11 {
      box-shadow: 0px 0px 6px 0px rgba(0, 0, 0, 0.06);
      background-color: rgba(255, 255, 255, 1);
      border-radius: 10px;
      position: absolute;
      left: 82px;
      top: -9px;
      width: 284px;
      height: 218px;
    }
  }
}

// 可拖动机器人样式
.floating-robot {
  position: fixed;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, #32c5ff, #1bb3ff);
  border-radius: 50%;
  cursor: pointer;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(50, 197, 255, 0.3);
  transition: all 0.3s ease;
  user-select: none;

  &:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(50, 197, 255, 0.4);
  }

  .robot-icon {
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .robot-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(50, 197, 255, 0.3);
    animation: pulse 2s infinite;
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(1.4);
    opacity: 0;
  }
}

// 聊天悬浮窗样式
.chat-floating-window {
  position: fixed;
  width: 900px;  // 增加宽度以容纳侧边栏
  height: 600px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;

  .chat-window-header {
    background: linear-gradient(135deg, #32c5ff, #1bb3ff);
    color: white;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    flex-shrink: 0;

    .chat-title {
      font-weight: 600;
      font-size: 16px;
    }

    .chat-controls {
      display: flex;
      gap: 4px;

      .el-button {
        color: white;
        padding: 4px 8px;
        min-height: auto;
        
        &:hover {
          background: rgba(255, 255, 255, 0.2);
        }
      }
    }
  }

  .chat-window-content {
    flex: 1;
    overflow: hidden;
    
    // 调整Chat组件样式以适应悬浮窗
    :deep(.chat-container) {
      height: 100%;
      border-radius: 0;
    }
    
    // 保留侧边栏，但调整宽度
    :deep(.sidebar) {
      width: 200px; // 减小侧边栏宽度
      flex-shrink: 0;
    }
    
    :deep(.main-content) {
      flex: 1;
    }
    
    // 调整历史记录列表样式
    :deep(.history-list) {
      max-height: 200px; // 限制历史记录高度
      overflow-y: auto;
    }
    
    // 调整历史记录项样式
    :deep(.history-item) {
      padding: 6px 12px; // 减小内边距
      font-size: 12px; // 减小字体
      
      .chat-title {
        font-size: 12px;
        margin-bottom: 2px;
      }
      
      .chat-time {
        font-size: 10px;
      }
    }
    
    // 调整菜单项样式
    :deep(.menu-item) {
      padding: 8px 12px; // 减小内边距
      font-size: 12px;
      
      .text {
        font-size: 12px;
      }
    }
    
    // 调整logo样式
    :deep(.logo) {
      padding: 12px 16px; // 减小内边距
      
      .logo-text {
        font-size: 14px; // 减小字体
      }
    }
  }
}

.dialog-footer {
  display: block;
  text-align: right;
  /* 确保内容右对齐 */
  margin-top: 16px;

  .dialog-button {
    width: 150px;
  }
}
</style>